Conversation
… for movie and customer.
Video StoreWhat We're Looking For
|
|
|
||
| # TODO: To make this happen automatically | ||
| def checkout | ||
| @rental = Rental.new(rental_params) |
There was a problem hiding this comment.
Since you're not rendering views, you shouldn't need instance variables in your controllers.
| self.due_date= (self.checkout_date + 7) | ||
| end | ||
|
|
||
| def build_rental |
There was a problem hiding this comment.
Nice job switching these from class methods to instance methods per our conversation
| new_inventory = self.movie.available_inventory -= 1 | ||
| customer_movie_count = self.customer.movies_checked_out_count += 1 | ||
|
|
||
| self.update_attribute(:checked_out, true) |
There was a problem hiding this comment.
When you're updating a single property, it is more overhead than necessary to use update_attribute. You should just set the property directly self.checked_out = true.
| require "test_helper" | ||
|
|
||
| describe Movie do | ||
| let(:movie) { Movie.new } |
There was a problem hiding this comment.
Looks like you aren't ever using this. While it is in a let block that will be lazy loaded, you still shouldn't have it if it never used.
|
|
||
| describe Rental do | ||
| describe 'relations' do | ||
| let(:rental1) { rentals(:rental1) } |
There was a problem hiding this comment.
Also looks like you're not using this variable
| end | ||
| end | ||
| describe 'validations' do | ||
| it "must be a valid rental" do |
There was a problem hiding this comment.
Will it be valid without a due date?
| @@ -0,0 +1,120 @@ | |||
| require "test_helper" | |||
|
|
|||
| describe MoviesController do | |||
| end | ||
|
|
||
| it "gets index with no movies" do | ||
| Movie.all.each { |movie| movie.destroy } |
Video Store API
Congratulations! You're submitting your assignment!
If you didn't get to the functionality the question is asking about, reply with what you would have done if you had completed it.
Comprehension Questions